package com.EAIPClub.userdatamanager.mapper;

import com.api.POJO.UserDataManager.Data.UserGroup;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description :用户所属用户组信息Mapper
 * @Author :崔昌赫
 * @Date : 2021/10/11
 */
@Mapper
@Repository
public interface UserGroupDataMapper {
    @Select("SELECT * FROM user_group")
    List<UserGroup> findAllUserGroupData();
    @Select("SELECT * FROM user_group WHERE uid='${uid}'")
    UserGroup findUserGroupDataByUid(@Param("uid") String uid);
    @Select("SELECT * FROM user_group WHERE groupId=${groupId}'")
    List<UserGroup> findUserGroupDataByGroupId(@Param("groupId") Integer groupId);

    @Insert("INSERT INTO user_group VALUES ('${userGroup.uid}',${userGroup.groupId})")
    Boolean addUserIntoUserGroup(@Param("userGroup") UserGroup userGroup);

    @Update("UPDATE user_group SET uid = '${nuid}' WHERE uid='${uid}'")
    Boolean updateUserUidByUid(@Param("nuid")String nuid,@Param("uid")String uid);
    @Update("UPDATE user_group SET groupId = '${groupId}' WHERE uid='${uid}'")
    Boolean updateUserGroupDataByUid(@Param("groupId")Integer groupId,@Param("uid")String uid);

    @Delete("DELETE FROM user_group WHERE uid='${uid}'")
    Boolean deleteUserGroupDataByUid(@Param("uid")String uid);
}
